#ifndef FILE_SE_Chrono_HPP
#define FILE_SE_Chrono_HPP

#include <ctime>
#include <vector>
#include "System.hpp"
#include "Types.hpp"

namespace se {

///////////////////////////////////////////////////////////////////////////////
/// \brief A basic chronometer
///
/// This class gives you a chronometer that you can pause, resume, and who may
/// have a father, meaning that when the father is paused, the "son"
/// chronometer will also be paused, and will preserve its previous state when
/// resumed. This behaviour is recursive, and you can have as many levels of
/// inheritance as you want.
///////////////////////////////////////////////////////////////////////////////
class System::Chrono{
	//
	//Member Functions
	//
		public:
			Chrono();
			Chrono(Chrono *father);
			Chrono(const Chrono& c);
			
			Chrono& operator=(const Chrono& c);
			
			//Accessors
			clock_t Time_fast() const;
			Time_t Time_ms() const;
			double Time_s() const;
			
			bool IsPaused() const;
			bool IsPausedGlobal() const;
			
			//Modiffications
			void Pause();
			void Resume();
			
			//Reseting
			void Restart();
			void SetFather(Chrono* father);
			void SetFather(Chrono& father);
			
			~Chrono();
		
		protected:
			void deleteChrono(Chrono* child);
			void ChangePauseLevelBy(int16_t m);
			static Time_t getGlobalTime();
			static uint64_t getTicsPerSecond();
	
	//
	//Attributes
	//
		private:
			Time_t m_timeElapsed;//relative
			Time_t m_timePaused;//absolute
			uint16_t m_pauseLevel;
			Chrono *m_father;
			std::vector<Chrono*> m_childs;

};

}// </namespace se>

#endif // FILE_se_Chrono_HPP
